package hot;

public class Num240 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int n = matrix.length;
        int m = matrix[0].length;
        int i = 0,j = m - 1;
        while(i < n && j < m && 0 <= i && 0 <= j) {
            if(matrix[i][j] == target) {
                return true;
            }else if(matrix[i][j] < target) {
                i++;
            }else {
                j--;
            }
        }
        return false;
    }
}
